package cn.ibizlab.core.oauth2.config;

import cn.ibizlab.util.security.GlobalSecurityConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * OAuth2资源服务：负责oauth模式下的身份令牌验证及用户身份重构
 */
@Slf4j
@Configuration
@EnableResourceServer
@ConditionalOnProperty(name = "ibiz.auth.security", havingValue = "oauth2", matchIfMissing = true)
public class OAuth2ResourceServerConfig extends ResourceServerConfigurerAdapter {

    @Autowired
    GlobalSecurityConfig globalSecurityConfig;

    /**
     * http安全配置
     * @param http
     * @throws Exception
     */
    @Override
    public void configure(HttpSecurity http) throws Exception {
        globalSecurityConfig.configure(http);
    }

}
